a=input()
b=0
c=0
d=0
if a=="[]{}()" or a=="[](){}" or a=="{}()[]" or a=="{}[]()" or a=="()[]{}" or a=="(){}[]":
    print("True")
elif len(a)==8:
    for i in  range(0,len(a)-5):
        if a[i]=='{' and a[i+1]=="}" or a[i+3]=="}" or a[i+5]=="}":
            b=b+1
        elif a[i]=='[' and a[i+1]=="]" or a[i+3]=="]" or a[i+5]=="]":
            c=c+1
        elif a[i]=='(' and a[i+1]==")" or a[i+3]==")" or a[i+5]==")":
            d=d+1
        elif a[i]=='<' and a[i+1]==">" or a[i+3]==">" or a[i+5]==">":
            d=d+1
    if b+c+d==3:
        print("True")
    else:
        print("False")
elif len(a)==6:
    for i in  range(0,len(a)-3):
        if a[i]=='{' and a[i+1]=="}" or a[i+3]=="}":
            b=b+1
        elif a[i]=='[' and a[i+1]=="]" or a[i+3]=="]":
            c=c+1
        elif a[i]=='(' and a[i+1]==")" or a[i+3]==")":
            d=d+1
    if b+c+d==3:
        print("True")
    else:
        print("False")
elif len(a)==4:
    if a[0]=='[' and a[1]=="]" or a[3]=="]":
        c=c+1
    if a[1]=='(' and a[2]==")":
        d=d+1
    if c+d==2:
        print("True")
    else:
        print("False")
elif len(a)==2:
    if a[0]=='(' and a[1]==")":
        d=d+1
    if d==1:
        print("True")
    else:
        print("False")
else:
    print("False")

    
